<template>
  <div class="goods-item" @click="itemClick">
    <img v-lazy="product.cover_url" alt="">
    <div class="goods-info">
      <p>{{product.title}}</p>
      <span class="price"><small>￥</small>{{product.price}}</span>
      <span class="collect iconfont">&#xe61e;&nbsp;{{product.collects_count}}</span>
    </div>
  </div>
</template>

<script>
import {useRouter} from 'vue-router'
export default {
  props:{
    product:{
      type:Object,
      default(){
        return {}
      }
    }
  },
  setup(props){
    const router=useRouter();
    const itemClick=()=>{
      router.push({path:'/detail',query:{id:props.product.id}})
    }
    return{
      itemClick
    }
  }

}
</script>

<style scoped lang="scss">
.goods-item{

  width: 46%;
  padding-bottom: 6px;
  position: relative;

  img{
    width: 100%;
    border-radius: 5px;

  }
  .goods-info{
    text-align: center;
    font-size: 12px;
    position: relative;
    top: 0px;
    overflow: hidden;
    p{
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      margin-bottom: 3px;
    }
    .price{
      color: red;
      margin-right: 20px;
    }
    .collect{
      font-size: 12px;
    }
  }
}
</style>